using System.Web.Mvc;
using Appetite.Data.EntityFramework.Repository;
using Appetite.Domain.Repository;
using Appetite.Presentation.Web.Controllers;
using Microsoft.Practices.Unity;
using Unity.Mvc3;

namespace Appetite.Presentation.Web
{
    public static class Bootstrapper
    {
        public static void Initialise()
        {
            var container = BuildUnityContainer();

            DependencyResolver.SetResolver(new UnityDependencyResolver(container));
        }

        private static IUnityContainer BuildUnityContainer()
        {
            var container = new UnityContainer();
            container.RegisterType<IRecipeRepository, RecipeRepository>();
            container.RegisterType<IRecipeCategoryRepository, RecipeCategoryRepository>();

            container.RegisterType<IFormsAuthentication, FormsAuthenticationService>();
            container.RegisterControllers();
            return container;
        }
    }
}